import requests
from config import url, headers_web, headers_wechat


class Homework:
    def __init__(self):
        self.url = url
        self.headers = headers_web

    @classmethod
    def get_correctable_answer(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:接口-获取老师可以批改的作业列表信息
        @Description:1、云课堂老师批改作业使用
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/cancorrectedanswers"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_info_by_id(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:根据课后作业id和学生id（或openId）查询作业详情
        @Description:云课堂web学生端使用
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/student/{paramspath}"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_stu_answer(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:接口-查询学生答题信息
        @Description:云课堂老师端查看学生作业详情使用
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/studentanswer"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_info_by_homeworkid(cls, url: str, params=None, headers=None, paramspath=None):
        """
        @Summary:接口-老师根据作业id获取作业详情（小程序使用）
        @Description:1、老师根据作业id获取作业详情（小程序使用）;2、云课堂老师端-获取已归档作业详情使用
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/teacherhomework/{paramspath}"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_student_homeworks(cls, url: str, params=None, headers=headers_wechat):
        """
        @Summary:接口-学生根据课程、班级获取作业列表
        @Description:1、微信小程序学生根据课程、班级获取作业列表
        :param url:
        :param params:
        :param headers:
        :return:
        """
        url = url + "/teachingApi/api/v1/homeworks/studenthomeworks"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_homeworks(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:根据课后作业id查询作业基本信息和解析
        @Description:
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_status_and_info(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:接口-获取课后作业状态和列表展示所需信息
        @Description:1、云课堂老师端教学内容列表异步加载使用
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/statusinfo"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_teacher_homeworks(cls, url: str, params=None, headers=headers_wechat):
        """
        @Summary:接口-老师根据课程、班级获取作业列表
        @Description:1、微信小程序老师根据课程、班级获取作业列表
        :param url:
        :param params:
        :param headers:
        :return:
        """
        url = url + "/teachingApi/api/v1/homeworks/teacherhomeworks"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_status_and_info_by_homeworkid(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:根据课后作业id和学生id（或openId）获取作业状态和列表展示所需信息
        @Description:云课堂web学生端使用
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/student/{paramspath}/statusinfo"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_student_answers(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:接口-根据作业id查询作业学生提交信息
        @Description:1、云课堂老师查看作业详情中学生表现使用
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/studentanswers"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_correct_student_answer(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:接口-获取学生提交作业和老师批改信息
        @Description:云课堂老师端批改学生作业使用
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/correctstudentanswer"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_student_answer_status(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:接口-查询课后作业学生答题状态信息
        @Description:
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/studentanswerstatus"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def get_good_homework(cls, url: str, params=None, headers=headers_web, paramspath=None):
        """
        @Summary:根据课后作业id查询优秀作业
        @Description:云课堂web学生端使用
        :param url:
        :param params:
        :param headers:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/student/goodhomework/{paramspath}"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def post_del_homework(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        @Summary:接口-删除课后作业接口
        @Description:1、云课堂老师端删除作业使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/del"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_homework_status(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        @Summary:接口-更改课后作业状态（立即开始、立即结束、归档）
        @Description:1、云课堂老师端教学内容列表中作业状态操作使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/status"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_answer(cls, url: str, params=None, headers=None, json=None):
        """
        @Summary:接口-学生提交作业、重新提交作业
        @Description:云课堂微信小程序学生提交、重新提交作业；学生端提交、重新提交作业使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :return:
        """
        url = url + "/teachingApi/api/v1/homeworks/student/answer"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_repulse_status(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None,
                            paramspath2=None):
        """
        @Summary:接口-老师打回学生提交作业
        @Description:1、云课堂老师端打回学生提交作业使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath：作业id
        :param paramspath2：学生回答信息id
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/studentanswers/{paramspath2}/repulsestatus"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_aloneurge(cls, url: str, params=None, headers=headers_web, json=None):
        """
        @Summary:接口-催交作业，催交特定未提交作业的学生
        @Description:1、云课堂老师端教学内容详情催交作业，催交特定未提交作业的学生使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :return:
        """
        url = url + "/teachingApi/api/v1/homeworks/aloneurge"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_correct_student_answer(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        @Summary:接口-老师批改作业
        @Description:1、云课堂老师端批改作业使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/studentanswers/correction"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_extend_time(cls, url: str, params=None, headers=headers_web, json=None):
        """
        @Summary:接口-课后作业延迟接口
        @Description:1、云课堂老师端教学内容课后作业使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :return:
        """
        url = url + "/teachingApi/api/v1/homeworks/extendTime"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_add_homework(cls, url: str, params=None, headers=headers_web, json=None):
        """
        @Summary:接口-添加/修改课后作业
        @Description:1、云课堂老师端教学内容添加/修改课后作业使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :return:
        """
        url = url + "/teachingApi/api/v1/homeworks"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_analysis_file(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        @Summary:接口-新增答案解析
        @Description:云课堂老师端新增答案解析使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath：
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/homeworkanalysisfile"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_send_mail(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None):
        """
        @Summary:接口-催交作业，催交所有未提交作业的学生
        @Description:1、云课堂老师端教学内容列表催交作业，催交所有未提交作业的学生使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath：
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/sendmail"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

    @classmethod
    def post_recommend_homework(cls, url: str, params=None, headers=headers_web, json=None, paramspath=None,
                                paramspath2=None):
        """
        @Summary:接口-课后作业学生回答推荐/取消推荐作业）
        @Description:1、云课堂老师端作业详情中推荐/取消推荐使用
        :param url:
        :param params:
        :param headers:
        :param json:
        :param paramspath
        :param paramspath2
        :return:
        """
        url = url + f"/teachingApi/api/v1/homeworks/{paramspath}/studentanswers/{paramspath2}/recommend"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r
